package com.example.demo.controller;

import com.example.demo.entity.ResponseBean;
import com.example.demo.service.TestServiceImpl;
import com.example.demo.service.WebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/test")
//@Api(description = "服务器向客户端推送消息接口", tags = "Test")
public class TestController {

   /* @Autowired
    private TestServiceImpl testServiceImpl;*/
    @Autowired
    private WebSocketServer webSocketServer;
    /**
     * 模拟数据发送
     */

    @GetMapping(value = "/sendTestMessage")
    public ResponseBean sendTestMessage(String message) {
        try {
            webSocketServer.sendAllMessage(message);
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseBean.error("群发出错",e);
        }
        return ResponseBean.ok("群发成功",message);
    }

   /* @PostMapping("/pushToWeb")
   // @ApiOperation(value = "服务器端向客户端推送消息", notes = "服务器端向客户端推送消息")
    public ResponseBean pushToWeb(*//**@RequestBody @ApiParam(value = "回收人编码和医院编码", required = true) *//*String info){

        testServiceImpl.printTime();
        return  ResponseBean.ok( "success", "123456");
    }*/

}

